from django.shortcuts import render
from loguru import logger
from rest_framework.request import Request
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters, status
import xml.etree.ElementTree as ET
from xml.etree.ElementTree import Element
from datetime import datetime

from apps.TabletInfo.filters import TabletInfoFilter
from apps.TabletInfo.serializers import ReadTabletinfoSerializer, WriteTabletinfoSerializer
from op_drf.dj_utils import set_delete, create_by_serializer
from op_drf.viewsets import CustomModelViewSet, ReadOnlyModelViewSet
from apps.TabletInfo.models import TabletInfo

# Create your views here.

class TabletInfoView(CustomModelViewSet):
    """
    处方信息的CRUD
    """
    queryset = TabletInfo.objects.filter()
    serializer_class = ReadTabletinfoSerializer  # 序列化器
    # 分页
    # pagination_class = Pagination
    # 筛选
    filter_backends = (DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter)
    filter_class = TabletInfoFilter
    search_fields = ("id", )
    filter_fields = ("id", )
    ordering_fields = ("-id",)
    ordering = ["-id"]